<template>
  <div class="m-card">
    <div class="card-top">
      <a href="#"><h3>猜你再追</h3></a>
    </div>
    <div class="card-bot" >
      <div class="card-box" v-for="item,index in cardlist" :key="index" @click="latestmovies(item.id)">
        <img :src="item.imgUrl" class="card-img-top" alt="...">
        <div>
          <a href="#" ><h5 class="card-title">{{item.name}}</h5></a>
          <p >{{item.director}}</p>
        </div>
      </div>
      
    </div>
  </div>
</template>

<script>
import {getMovieList} from '@/api/movie'
export default {
  name:'Card',
  data(){
    return{
      cardlist:[]
    }
  },
  created(){
    getMovieList({}).then(res=>{
      let data = res.data
      // console.log(data)
      this.cardlist = data.data.list.slice(0,6)
    })
  },
  methods:{
    latestmovies(id){
      this.$router.push('/latestmovies')
      this.$router.push({path:'/latestmovies', query:{id:id}})
    }
  }
}
</script>

<style scoped>
  .card-top{
    width: 100%;
    height: 50px;
    margin: 0 auto;
    margin-top: 20px;
  }
  .card-top h3{
    position: absolute;
    margin: 8px 0 0 20px;
    color: #000;
  }
  .card-top h3:hover{
    color: rgb(11, 52, 165);
  }
  .card-bot{
    padding-top: 6px;
    width: 100%;
    height: 170px;
    margin: 0 auto;
    display: flex;
    justify-content: space-evenly;
  }
  .card-box{
    width: 200px;
    /* border: 1px solid #eee; */
    border-radius:5px 5px 0 0;
  }
  .card-bot .card-img-top{
    width: 15vmax;
    height: 100px;
    border-radius: 5px;
  }
  .card-title {
    margin-top: 10px;
    margin-bottom: 0;
  }
  h5{
    color: #fff;
  }
  .card-bot p{
    margin-bottom: 0;
    color: #000;
  }
</style>